package com.ryx.controller;

import com.ryx.aop.annotation.MyLog;
import com.ryx.constants.Constant;
import com.ryx.service.HomeService;
import com.ryx.utils.DataResult;
import com.ryx.utils.JWTTokenUtil;
import com.ryx.vo.resp.HomeRespVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @BelongsPackage: com.ryx.controller
 * @Author: 容永轩
 * @CreateTime: 2020-12-23
 * @Description:
 */
@RestController
@RequestMapping("/api")
@Api(tags = "首页模块！")
public class HomeController {

    @Autowired
    private HomeService homeService;

    @GetMapping("/home")
    @MyLog(title = "首页模块",action = "获取首页数据接口")
    public DataResult<HomeRespVo> getHome(HttpServletRequest request ){
        String accessToken = request.getHeader(Constant.ACCESS_TOKEN);
        String userId = JWTTokenUtil.getUserId(accessToken);

        DataResult result = DataResult.success();
        result.setData(homeService.getHome(userId));

        return result;
    }



}
